import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// 引入自动导入插件
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
export let VUE_APP_BASE_API = 'http://2416.zhiceweilai.cn/api'

export default defineConfig({
    base: './', // 这里更改打包相对绝对路径
    minify: true, // 是否压缩代码
    sourceMap: false, // 是否生成sourceMap
    esbuild: {
        drop: ['console', 'debugger'],
    },
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
            imports: ['vue', 'vue-router'],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('src', import.meta.url)),
        },
    },
    server: {
        proxy: {
            // '/url': {
            //     target: 'http://2416.zhiceweilai.cn',
            //     // target: 'http://2416.zhiceweilai.cn/pc',
            //     changeOrigin: true, //是否跨域
            //     secure: false, //是否https接口
            //     rewrite: (path) => {
            //         return path.replace(/^\/url/, '')
            //     },
            // },
            // '/xx': {
            //     target: 'http://120.26.101.133:8183',
            //     changeOrigin: true, //是否跨域
            //     secure: false, //是否https接口
            //     rewrite: (path) => {
            //         return path.replace(/^\/xx/, '')
            //     },
            // },
        },

        host: '0.0.0.0',
    },
})
